﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SunshineAirlines.UserControls
{
    public partial class flightNonStop : UserControl
    {
        public flightNonStop()
        {
            InitializeComponent();
        }

        private string cabinType;
        private string fltNum;
        private string depCity;
        private string depTime;
        private string arrCity;
        private string arrTime;
        private int totalTime;
        private double price;
        private int availableTickets;
        private double delayRate;

        public double Price
        {
            get
            {
                return price;
            }

            set
            {
                price = value;
                lblPrice.Text = string.Format(lblPrice.Text, price);
            }
        }

        public string CabinType
        {
            get
            {
                return cabinType;
            }

            set
            {
                cabinType = value;
                lblCabin.Text = cabinType;
            }
        }

        public string FltNum
        {
            get
            {
                return fltNum;
            }

            set
            {
                fltNum = value;
                lblFLTnum.Text = string.Format("Flight {0} ({1:P})", fltNum, delayRate);
            }
        }

        public string DepCity
        {
            get
            {
                return depCity;
            }

            set
            {
                depCity = value;
                lblDEP.Text = depCity;
            }
        }

        public string DepTime
        {
            get
            {
                return depTime;
            }

            set
            {
                depTime = value;
                lbltimeDEP.Text = string.Format(lbltimeDEP.Text, Convert.ToDateTime(depTime));
            }
        }

        public string ArrCity
        {
            get
            {
                return arrCity;
            }

            set
            {
                arrCity = value;
                lblARR.Text = arrCity;
            }
        }

        public string ArrTime
        {
            get
            {
                return arrTime;
            }

            set
            {
                arrTime = value;
                lbltimeARR.Text = string.Format(lbltimeARR.Text, Convert.ToDateTime(arrTime));
            }
        }

        public int TotalTime
        {
            get
            {
                return totalTime;
            }

            set
            {
                totalTime = value;
                TimeSpan ts = TimeSpan.FromMinutes(totalTime);
                lblTotalTime.Text = string.Format(lblTotalTime.Text, ts.Hours, ts.Minutes);

            }
        }

        public int AvailableTickets
        {
            get
            {
                return availableTickets;
            }

            set
            {
                availableTickets = value;
                lblavl.Text = string.Format(lblavl.Text, availableTickets);
                if (availableTickets <= 3) lblavl.ForeColor = System.Drawing.Color.Red;
            }
        }

        public double DelayRate
        {
            get
            {
                return delayRate;
            }

            set
            {
                delayRate = value;
                lblFLTnum.Text = string.Format("Flight {0} ({1:P})", fltNum, delayRate);
                if (delayRate == 0) lblFLTnum.Text = "Flight " + fltNum;
            }
        }
    }
}
